
		<link rel="stylesheet" type="text/css" href="<?php echo Yii::app ()->request->baseUrl; ?>/css/menu/dock.css" />

		<?php 

$cs = Yii::app ()->getClientScript (); 
// $cs = Yii::app ()->getClientScript()->registerCoreScript ('jquery'); 
$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/jquery-1.7.1.min.js");
$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/menu/jquery.fixedMenu.js");
$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/Base.js");
$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/fancybox/jquery.fancybox-1.3.4.js");
$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/fancybox/jquery.mousewheel-3.0.4.pack.js");
$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/menu/jquery.opacityrollover.js");
$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/menu/jquery.galleriffic.js");
$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/menu/jquery.history.js");

		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/Three.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Clock.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Color.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Edge.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Face3.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Face4.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Geometry.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Math.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Vector2.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Vector3.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Vector4.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Matrix3.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Matrix4.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Object3D.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Projector.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Quaternion.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Ray.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Rectangle.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Spline.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/UV.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/core/Vertex.js");

		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/cameras/Camera.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/cameras/OrthographicCamera.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/cameras/PerspectiveCamera.js");
		
		
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/lights/Light.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/lights/AmbientLight.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/lights/DirectionalLight.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/lights/PointLight.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/lights/SpotLight.js");
		
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/Material.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/LineBasicMaterial.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/MeshBasicMaterial.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/MeshLambertMaterial.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/MeshPhongMaterial.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/MeshDepthMaterial.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/MeshNormalMaterial.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/MeshPhongMaterial.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/MeshFaceMaterial.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/MeshShaderMaterial.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/ParticleBasicMaterial.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/ParticleCanvasMaterial.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/ParticleDOMMaterial.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/materials/ShaderMaterial.js");
		
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/textures/Texture.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/textures/DataTexture.js");
		
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/objects/Particle.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/objects/ParticleSystem.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/objects/Line.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/objects/Mesh.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/objects/Bone.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/objects/SkinnedMesh.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/objects/Ribbon.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/objects/LOD.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/objects/Sprite.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/objects/MorphAnimMesh.js");
		
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/scenes/Scene.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/scenes/Fog.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/scenes/FogExp2.js");
		
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/DOMRenderer.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/CanvasRenderer.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/SVGRenderer.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/WebGLShaders.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/WebGLRenderer.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/WebGLRenderTarget.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/WebGLRenderTargetCube.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/renderables/RenderableVertex.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/renderables/RenderableFace3.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/renderables/RenderableFace4.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/renderables/RenderableObject.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/renderables/RenderableParticle.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/renderers/renderables/RenderableLine.js");
		
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/ColorUtils.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/GeometryUtils.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/ImageUtils.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/SceneUtils.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/ShaderUtils.js");
		
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/animation/AnimationHandler.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/animation/Animation.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/animation/AnimationMorphTarget.js");
		
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/cameras/FirstPersonCamera.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/cameras/CombinedCamera.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/cameras/CubeCamera.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/cameras/PathCamera.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/cameras/FlyCamera.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/cameras/RollCamera.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/cameras/TrackballCamera.js");
		
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/controls/FirstPersonControls.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/controls/FlyControls.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/controls/PathControls.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/controls/RollControls.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/controls/TrackballControls.js");
		
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/core/Curve.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/core/CurvePath.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/core/Path.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/core/Shape.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/core/TextPath.js"); 
		
		
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/geometries/CubeGeometry.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/geometries/CylinderGeometry.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/geometries/ExtrudeGeometry.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/geometries/IcosahedronGeometry.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/geometries/LatheGeometry.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/geometries/OctahedronGeometry.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/geometries/PlaneGeometry.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/geometries/SphereGeometry.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/geometries/TextGeometry.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/geometries/TorusGeometry.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/geometries/TorusKnotGeometry.js");
		
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/loaders/Loader.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/loaders/JSONLoader.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/loaders/BinaryLoader.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/loaders/ColladaLoader.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/loaders/SceneLoader.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/loaders/UTF8Loader.js");
		
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/modifiers/SubdivisionModifier.js");
		
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/objects/MarchingCubes.js");
		// $cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/objects/Trident.js");
		
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/renderers/AnaglyphWebGLRenderer.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/renderers/CrosseyedWebGLRenderer.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/renderers/ParallaxBarrierWebGLRenderer.js");
		
		// $cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/physics/Collisions.js");
		// $cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/extras/physics/CollisionUtils.js");
		
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/RequestAnimationFrame.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/fonts/helvetiker_regular.typeface.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/Stats.js");
		
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/menu/jquery.fixedMenu.js");
		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/menu/dock.js");
   		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/Detector.js");
    	$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/threejs/DAT.GUI.min.js");
    	$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/room/Facility.js");
 		$cs->registerScriptFile(Yii::app ()->request->baseUrl. "/js/room/House.js");

?>


<?php include  dirname(__FILE__).'/toolbar.php';?>		
	
<div class='buttons'>

</div>

	   <script type="text/javascript">

  jQuery(document).ready(function($) {
      //if ( ! Detector.webgl ) Detector.addGetWebGLMessage();

      var container, stats;
      var camera, scene, renderer;
      var projector, plane, cube;
      var mouse2D, mouse3D, ray,
      rollOveredFace, isShiftDown = false,
      theta = 45, isCtrlDown = false;

      var rollOverMesh, rollOverMaterial;
      var cubeGeo, cubeMaterial;
      var i, intersector;
      var info;
      var stageWidth,stageHeight;
      var objects=[];
      var centerOffset;
      var rollOverMesh;
	  var stageSize;
	  var house;
	  var gid;
	  var cameraTarget;
	  var gui, voxelConfig = {
				orthographicProjection: false
			};

      init();
      animate();
    
      function init() {

        container = document.createElement( 'div' );
        //document.body.appendChild( container );
        $('.stage').append(container);

        stageWidth=window.innerWidth;
        stageHeight=window.innerHeight;
		    stageSize={width:stageWidth,height:stageHeight};
		    
		    cameraTarget = new THREE.Vector3( 0, 0, 0 );
				camera = new THREE.CombinedCamera( stageSize.width, stageSize.height, 45, 1, 10000, -2000, 10000 );
				camera.position.y = 800;

        scene = new THREE.Scene();

        // // roll-over helpers
// 
       // rollOverGeo = new THREE.CubeGeometry( 50, 50, 50 );
       // rollOverMaterial = new THREE.MeshBasicMaterial( { color: 0xff0000, opacity: 0.5, transparent: true } );
       // rollOverMesh = new THREE.Mesh( rollOverGeo, rollOverMaterial );
       // scene.addObject( rollOverMesh );


        // cubes

        cubeGeo = new THREE.CubeGeometry( 200, 200, 200 );
        cubeMaterial = new THREE.MeshLambertMaterial( { color: 0x00ff80, shading: THREE.FlatShading, map: THREE.ImageUtils.loadTexture( "textures/square-outline-textured.png" ) } );
        cubeMaterial.color.setHSV( 0.1, 0.7, 1.0 );
        cube = new THREE.Mesh( cubeGeo, cubeMaterial );
        cube.name='cube';
        cube.position.y=100;
        cube.index=objects.length;
        // scene.addObject( cube ) ;
        // objects.push(cube);
        // picking

        projector = new THREE.Projector();

        // grid

        // plane = new THREE.Mesh( new THREE.PlaneGeometry( 1000, 1000, 20, 20 ), new THREE.MeshBasicMaterial( { color: 0x999933, wireframe: true } ) );
        // plane.rotation.x = - 90 * Math.PI / 180;
        // plane.name="background";
        // scene.addObject( plane );
		plane = new THREE.Mesh( new THREE.PlaneGeometry( 1000, 1000, 20, 20 ), new THREE.MeshBasicMaterial( { color: 0x555555, wireframe: true } ) );
		plane.rotation.x = - 90 * Math.PI / 180;
		plane.name="background";
		scene.add( plane );
		
		

        mouse2D = new THREE.Vector3( 0, 10000, 0.5 );
        centerOffset=new THREE.Vector3( 0, 0, 0);
        

		// Lights

				var ambientLight = new THREE.AmbientLight( 0x606060 );
				scene.add( ambientLight );

				var directionalLight = new THREE.DirectionalLight( 0xffffff );
				directionalLight.position.set( 1, 0.75, 0.5 ).normalize();
				scene.add( directionalLight );

				renderer = new THREE.WebGLRenderer( { antialias: true, preserveDrawingBuffer : true } );
				renderer.setSize( window.innerWidth, window.innerHeight );

        		container.appendChild( renderer.domElement );


				// add GUI
				gui = new DAT.GUI();
				gui.add(voxelConfig, 'orthographicProjection').onChange(function(){

					if ( voxelConfig.orthographicProjection ) {
						camera.toOrthographic();
						camera.position.x = 1000;
               			camera.position.y = 707.106;
                		camera.position.z = 1000;
						theta = 90;
					} else {
						camera.toPerspective();
						camera.position.y = 800;
					}

				});
				gui.close();
				
        // stats = new Stats();
        // stats.domElement.style.position = 'absolute';
        // stats.domElement.style.top = '0px';
        // container.appendChild( stats.domElement );
        facility=new Facility();
        $('.stage canvas').bind('click',function(event){getFocus(event);}); 
		// $('.stage canvas').bind('mousemove',{zmesh:rollOverMesh},moveMesh); 
        //document.addEventListener( 'mousemove', onDocumentMouseMove, false );
        //document.addEventListener( 'mousedown', onDocumentMouseDown, false );
        //document.addEventListener( 'keydown', onDocumentKeyDown, false );
        //document.addEventListener( 'keyup', onDocumentKeyUp, false );

      }

      //

      function animate() {

        requestAnimationFrame( animate );

        render();
        // stats.update();

      }

      function render() {

				facility.setMeshOnBoard(plane,scene, camera);
				camera.position.x = 1400 * Math.sin( theta * Math.PI / 360 );
				camera.position.z = 1400 * Math.cos( theta * Math.PI / 360 );

				camera.lookAt( cameraTarget );
				renderer.render( scene, camera );

      }

    buildHouse=function(roomStyles){
    	
    	house=new House(camera,scene);
    	house.build(roomStyles);

      
    }
	quoteMesh=function(goodsGeo,event){   
			event.preventDefault();
			facility.createMesh(goodsGeo);
			scene.add(facility.zmesh);
			$('.stage canvas').unbind('click');
			showButtons(event);
			// $('.stage canvas').bind('mousemove',{stageSize:stageSize,plane:plane},move); 
			// $('.stage canvas').bind('click',{stageSize:stageSize,objects:objects},locate);
      	}
			
			var move=function(event){

				event.preventDefault();

				mouse2D.x = ( event.clientX / window.innerWidth ) * 2 - 1;
				mouse2D.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
				facility.move(event);
			};
      
      var getFocus=function(event){
        projector = new THREE.Projector();
        mouse2D = new THREE.Vector3( 0, 10000, 0.5 );
        mouse2D.x = ( event.clientX / stageSize.width ) * 2 - 1;
        mouse2D.y = - ( event.clientY / stageSize.height ) * 2 + 1;
        
        mouse3D = projector.unprojectVector( mouse2D.clone(), camera );
        var ray = new THREE.Ray( camera.position, mouse3D.subSelf(camera.position ).normalize() );

        var intersects = ray.intersectObjects( objects );

        if ( intersects.length > 0 ) {

          if(facility.zmesh==null){
             // facility.setMesh(intersects[ 0 ].object);
             showButtons(event);
          }

          container.style.cursor = 'move';
         
          
          
          $('.stage canvas').bind('click',{stageSize:stageSize,objects:objects},locate);
          // $('.stage canvas').bind('keydown',function(event){alert('dd');});
          //$( '.buttons' ).load("/index.php?r=webgl/asdfasd");
        }
      };
	var showButtons= function (event) {

	
	$( '.buttons' ).load("index.php?r=webgl/buttons",{x:event.clientX,y:event.clientY},function(){
			$("#move").click(function(){
  				$('.stage canvas').bind('mousemove',{stageSize:stageSize,plane:plane},move);
  				$('.stage canvas').bind('click',{stageSize:stageSize,objects:objects},locate);
			});
			$("#rotate").click(function(){
  				$('.stage canvas').bind('mousemove',{curmouse:{x:event.clientX,y:event.clientY}},rotate);
			});
			
			 $(".tool").click(function(){
			 	$( ".block" ).animate({
    				width:"0px"
				  }, {
					duration: 300
				});
				$( ".tool" ).animate({
					width:"0px"
				},{duration: 300
				});
			});
	});
	

	};
		var locate=function(event){
        // facility.isCollided(event);
        if(house)
        house.goods.push(facility.goods);
				facility.locate(event);
				$('.stage canvas').unbind('mousemove');
				$('.stage canvas').unbind('click');
				objects.push(facility.zmesh);
				$('.stage canvas').bind('click',function(event){getFocus(event);});
				// objects.splice(facility.zmesh.index,1);
				// // objects.push(facility.zmesh);
				// if(!facility.isCollided(event)){
						          // $('.stage canvas').unbind('mousemove');
						          // $('.stage canvas').unbind('click');
						          // facility.zmesh.index=objects.length;
						          // objects.push(facility.zmesh);
						          // facility.zmesh=null;
						          // $('.stage canvas').bind('click',function(event){getFocus(event);});
				// }   
		
			};

  var rotate=function(event){
  	
      facility.rotate(event);
  };
			

		var saveHouse=function(){
			
		}
			
				});


		</script>
	
<div class='stage'>

</div>



